<?php
//this is for qc approval form....
class Data_approval extends controller{

	function data_approval()
	{
	 	parent::Controller();
		$this->load->helper('url');
		$this->load->helper('form');
		$this->load->helper('approval');
		$this->load->model('caf_model');
		
	}
	function data_list()
	{
		$this->load->helper('flexigrid');
		
		
		$displayform = '';
		$displayform .='<div id=dashboard ><span>Data Approval Screen,QC</span> <a href='.base_url().'/idea_home/dashboard ><img align=right src="'.base_url().'images/home.png" alt="home" /></a><img align=right src="'.base_url().'images/back.png" id="back"" alt="back" ONCLICK="history.go(-1)" /></div>';
		
		$displayform .= '<br/>';
				
		$displayform .= '<table id="flex1" style="display:none" border=0 align=left ></table>';
		
		$colModel['id'] = array('ID',60,TRUE,'center',2);
		$colModel['batch_mobilenum'] = array('Mobile Number',120,TRUE,'center',0);
		$colModel['caf_customername'] = array('Customer Name',180,TRUE,'center',1);
	//	$colModel['status'] = array('Status',92,TRUE,'center',1);
		$gridParams = array(
			'width' => '520',
			'height' => 400,
			'rp' => 15,
			'rpOptions' => '[10,15,20,30]',
			'pagestat' => 'Displaying:{from} to {to} of {total} items.',
			'blockOpacity' => 0.5,
			'title' => 'QC Data List',
			'showTableToggleBtn' => true
		);
		
		$grid_js = build_grid_js('flex1',site_url("/ajax/approve_list"),$colModel,'caf_id','asc',$gridParams);
		
		$data['js_grid'] = $grid_js;	
		$data = array('formdisplay'=>$displayform,'js_grid'=>$grid_js );	
		$this->template->add_css('css/flexigrid/flexigrid.css');
		$this->template->add_js('js/flexigride/jquery.pack.js');
		$this->template->add_js('js/flexigride/flexigrid.pack.js');
		
		//ends here....
		$this->template->write_view('header','header', $data, True);
		$this->template->write_view('content', 'general_flexigrid');
		$this->template->render();
		
		
	}
	function scan_qc($id=0)
	{
		$displayform = '';
		
		$displayform .= '<div id=dashboard ><span>Data Approval Screen,QC</span> <a href='.base_url().'/idea_home/dashboard ><img align=right src="'.base_url().'images/home.png" alt="home" /></a><img align=right src="'.base_url().'images/back.png" id="back"" alt="back" ONCLICK="history.go(-1)" /></div>';
		$displayform .= '<br/>';
		$displayform .= form_open_multipart('data_approval/save_approval');
		$displayform .= '<div id=div_data_approval>';
		
		//to fetched approved qc details to get approved...
		$result = $this->caf_model->fetch_approvedqc($id);
		$values = $result->result_array();
		
		$dropdown_value = $this->caf_model->fetch_poi($values[0]['caf_poitype1']);
		
		$dropdown_result = $dropdown_value->result_array();
		
		$dropdown = $this->caf_model->fetch_poi();
		
		$all_dropdown = $dropdown->result_array();		
		$displayform .= approved_method($values,$dropdown_result,$all_dropdown);
		
		
		
		$displayform .= '</div>';
		$displayform .= '<div id=div_scanned_doc>';
		$displayform .= '<fieldset id=personal_details>';
		$displayform .= '<legend>Scanned Documents</legend>';
		$displayform .= '<input type="file" name="userfile[]" size="20" class="multi" accept="jpg|png|jpeg"/>';
		$displayform .= '</fieldset>';
      $displayform .= '<div style="padding:200px 0px 0px 0px;">';
    $displayform .= '<table align=left  width=100%>';
    $displayform .= '<tr><td colspan=2 align=center>';
    $displayform .= "<input type=radio name=status value=approve id=approve checked=checked />Approve &nbsp;";
    $displayform .= "<input type=radio name=status value=reject id=reject /> Reject &nbsp;";
    $displayform .= '</td></tr>';
    $displayform .= '<tr>';
    $displayform .= '</table>';
    $displayform .= '</div>';
		$displayform .= '</div>';
	
		$displayform .= '<div id="div_app_button" >';
		$displayform .= '<input type=submit name=submit value=Save class="ui-button ui-widget ui-state-default ui-corner-all" />&nbsp;&nbsp;&nbsp;';
		$displayform .= '<input type=reset value=cancel name=cancel class="ui-button ui-widget ui-state-default ui-corner-all" />';
		$displayform .= '</div>';
		$displayform .= form_close();
		$data = array('formdisplay'=>$displayform );
		$this->template->add_js('js/ui/jquery.ui.datepicker.js');
		$this->template->add_js('js/jquery.MultiFile.min.js');
		$this->template->add_js('
				$(function() {
			$( ".datepicker" ).datepicker(			
			{
			dateFormat: "dd/mm/yy",
			yearRange: "1900:2010",
			changeMonth: true,
			changeYear: true,
			showOn: "button",
			buttonImage: "'.base_url().'images/calendar.gif",
			buttonImageOnly: true
		
		});
		
		});

		','embed');
		
		$this->template->write_view('header','header', $data, True);
		$this->template->write_view('content', 'other_general');
		$this->template->render();
		
	}
	
		
	function save_approval()
	{
		 $this->caf_model->save_approved();
		 redirect("data_approval/data_list");
	}
	

	
	
}
